package com.dede.net_speed_monitor.util;

import android.content.Context;

/**
 * Created by hsh on 2017/3/24 024 上午 11:25.
 */
public class UIUtil {

    private UIUtil() {
    }

    public static float dp2pxFloat(Context context, float dpValue) {
        final float density = context.getResources().getDisplayMetrics().density;
        return dpValue * density;
    }

    public static int dp2pxInt(Context context, float dpValue) {
        final float density = context.getResources().getDisplayMetrics().density;
        return (int) (dpValue * density + 0.5f);
    }

    public static float sp2pxFloat(Context context, float dpValue) {
        final float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
        return dpValue * scaledDensity;
    }

    public static int sp2pxInt(Context context, float dpValue) {
        final float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;
        return (int) (dpValue * scaledDensity + 0.5f);
    }
}
